package nbcp

import org.bson.types.ObjectId
import nbcp.MainApplication
import org.junit.runner.RunWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.context.support.FileSystemXmlApplicationContext
import org.springframework.context.support.GenericXmlApplicationContext
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
import org.springframework.test.context.web.WebAppConfiguration
import org.springframework.test.web.servlet.MockMvc
import nbcp.base.utils.CodeUtil
import nbcp.base.utils.SpringUtil



/**
 * Created by udi on 17-3-27.
 */


@RunWith(SpringRunner::class)
@WebAppConfiguration
@AutoConfigureMockMvc
@SpringBootTest(classes = arrayOf(MainApplication::class))
@TestPropertySource(locations = arrayOf("classpath:application.yml","classpath:application-dev.yml"))
//@ActiveProfiles("unittest","productprofile")
abstract class TestBase {
    @Autowired
    protected var mvc: MockMvc? = null

    init {
        GenericXmlApplicationContext().environment.setActiveProfiles("test")
        System.setProperty("server.dbIp", "lzh");
        System.setProperty("shop.scheduler","false")
        System.setProperty("shop.mq.consumer","false")
        //ParserConfig.getGlobalInstance().putDeserializer(ObjectId::class.java, ObjectIdDeserializer())
    }
}